Page({
  data: {
    favorites: []
  },

  onLoad: function() {
    this.loadFavorites();
  },

  onShow: function() {
    // 每次显示页面时重新加载收藏列表
    this.loadFavorites();
  },

  loadFavorites: function() {
    // 从本地存储获取收藏数据
    const favorites = wx.getStorageSync('favorites') || [];
    this.setData({
      favorites: favorites
    });
  },

  onSpotTap: function(e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/detail/detail?id=${id}`
    });
  },

  goToIndex: function() {
    wx.switchTab({
      url: '/pages/index/index'
    });
  }
}); 